import { QualityType } from "../consts/quality_type";
import { Unit } from "./unit";
import { GlobalConfig } from "../../config/global/global_config";
import { UnitType } from "../consts/unit_type";



export class Monster extends Unit{
    quality:QualityType;
    name:string;
    id:string;
    attack:number;
    hp:number;
    level:number;
    exp:number;
    money:number;
    weaponId:string;

    init(id="21101",lv){
        this.id=id;
        this.unitId=this.id;
        let monster=<Monster>GlobalConfig.ins().monster[String(id)];
        // console.log("monster...",monster)
        monster.level=lv;
        this.level=lv;
        this.exp=monster.exp*GlobalConfig.ins().player[monster.level].monsterExp;
        // console.log("treasure",GlobalConfig.ins().treasure,this.quality);
        this.money=GlobalConfig.ins().treasure["白"].price*monster.money;
        this.quality=monster.quality;
        this.name=monster.name;
        this.quality=monster.quality;
        this.weaponId=monster.weaponId;
        switch(this.quality){
            case QualityType.白:
            default:
            this.attack=monster.attack*GlobalConfig.ins().player[monster.level].wAttack;
            this.maxHp=monster.hp*GlobalConfig.ins().player[monster.level].wHp;
            break;
            case QualityType.绿:
            this.attack=monster.attack*GlobalConfig.ins().player[monster.level].gAttack;
            this.maxHp=monster.hp*GlobalConfig.ins().player[monster.level].gHp;
            break;
            case QualityType.紫:
            this.attack=monster.attack*GlobalConfig.ins().player[monster.level].pAttack;
            this.maxHp=monster.hp*GlobalConfig.ins().player[monster.level].pHp;
            break;
            case QualityType.橙:
            this.attack=monster.attack*GlobalConfig.ins().player[monster.level].oAttack;
            this.maxHp=monster.hp*GlobalConfig.ins().player[monster.level].oHp;
            break;
        }
        this.setCurHp(this.maxHp);
        this.attackOverTime= Date.now();
        this.unitType=UnitType.怪物;
    }
    
}